package bb.lanxing.databinding;

import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.text.Html;
import android.text.format.DateFormat;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import androidx.core.content.res.ResourcesCompat;

import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.request.RequestOptions;
import com.github.mikephil.charting.utils.Utils;
import com.tencent.connect.common.Constants;

import org.apache.commons.cli.HelpFormatter;

import java.io.File;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Date;

import bb.lanxing.App;
import bb.lanxing.R;
import bb.lanxing.activity.base.WebActivity;
import bb.lanxing.activity.bluetooth.light.LightDeviceState;
import bb.lanxing.databinding.unit.AltitudeUnit;
import bb.lanxing.databinding.unit.DistanceUnit;
import bb.lanxing.databinding.unit.HeightUnit;
import bb.lanxing.databinding.unit.SpeedUnit;
import bb.lanxing.databinding.unit.Unit;
import bb.lanxing.databinding.unit.UnitConstants;
import bb.lanxing.databinding.unit.WeightUnit;
import bb.lanxing.databinding.utils.DateUtil;
import bb.lanxing.databinding.utils.FGSettingsConstants;
import bb.lanxing.databinding.utils.FormatterUtil;
import bb.lanxing.databinding.utils.SGSettingsConstants;
import bb.lanxing.databinding.utils.SizeFormatter;
import bb.lanxing.databinding.utils.SpanClickHelper;
import bb.lanxing.device.sgdevcie.tool.XossDeviceConstants;
import bb.lanxing.devicelist.tool.XossModelUtil;
import bb.lanxing.lib.devices.api.SmartDevice;
import bb.lanxing.lib.devices.ble.ble.characteristic.BatteryStatus;
import bb.lanxing.lib.devices.ble.ble.characteristic.BodySensorLocation;
import bb.lanxing.lib.devices.ble.ble.characteristic.light.LightMachineStatus;
import bb.lanxing.lib.devices.core.utils.DeviceHelper;
import bb.lanxing.util.DensityUtil;
import bb.lanxing.util.ui.ImageTextView;
import gov.nist.core.Separators;
//import bb.lanxing.utils.DateUtil;


public class DataBindingAdapters {
    public static DecimalFormat decimalFormat = new DecimalFormat("0");
    public static DecimalFormatSymbols dfs;

    public static int getDeviceNameResource(int i) {
        if (i != 9) {
            switch (i) {
                case 26:
                    return R.string.device_cycplus_m2;
                case 27:
                    return R.string.device_chileaf_600;
                case 28:
                    return R.string.st_nav_name;
                case 29:
                    return R.string.device_cycplus_m1;
                default:
                    return R.string.device_xoss_g_and_g_plus;
            }
        }
        return R.string.device_sprint_title;
    }

    static {
        DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
        dfs = decimalFormatSymbols;
        decimalFormatSymbols.setDecimalSeparator('.');
    }

    public static void setImageDrawable(ImageView imageView, Drawable drawable) {
        imageView.setImageDrawable(drawable);
    }

    public static void setImageResource(ImageView imageView, int i) {
        imageView.setImageResource(i);
    }

    public static void setBackgroundResource(TextView textView, int i) {
        textView.setBackgroundResource(i);
    }

    public static void loadImageWithGlide(ImageView imageView, Object obj, Object obj2, Object obj3) {
        RequestBuilder<Drawable> load;
        RequestOptions requestOptions = new RequestOptions();
        if (obj2 instanceof Drawable) {
            requestOptions.placeholder((Drawable) obj2);
        }
        if (obj2 instanceof Integer) {
            requestOptions.placeholder((Integer) obj2);
        }
        if (obj3 instanceof Drawable) {
            requestOptions.error((Drawable) obj3);
        }
        if (obj3 instanceof Integer) {
            requestOptions.error((Integer) obj3);
        }
        RequestManager applyDefaultRequestOptions = Glide.with(App.getContext()).applyDefaultRequestOptions(requestOptions);
        if (obj instanceof String) {
            load = applyDefaultRequestOptions.load((String) obj);
        } else if (obj instanceof Uri) {
            load = applyDefaultRequestOptions.load((Uri) obj);
        } else if (obj instanceof Drawable) {
            load = applyDefaultRequestOptions.load((Drawable) obj);
        } else if (obj instanceof Bitmap) {
            load = applyDefaultRequestOptions.load((Bitmap) obj);
        } else if (obj instanceof Integer) {
            load = applyDefaultRequestOptions.load((Integer) obj);
        } else if (obj instanceof File) {
            load = applyDefaultRequestOptions.load((File) obj);
        } else if (obj instanceof Byte[]) {
            load = applyDefaultRequestOptions.load((Object) ((Byte[]) obj));
        } else {
            load = applyDefaultRequestOptions.load(obj);
        }
        load.into(imageView);
    }

    public static void setColorTint(ImageView imageView, int i) {
        imageView.setColorFilter(i);
    }

    public static void bindIsSupport(View view, Boolean bool) {
        if (bool == null) {
            view.setVisibility(View.GONE);
        } else {
            view.setVisibility(bool ? View.VISIBLE : View.GONE);
        }
    }

    public static void visibility(View view, Boolean bool) {
        if (bool == null) {
            view.setVisibility(View.GONE);
        } else {
            view.setVisibility(bool ? View.VISIBLE : View.GONE);
        }
    }

    /*public static void supportModel(View view, boolean z, int i, String str) {
        if (z) {
            if (XossModelUtil.Companion.getInstance().isGen1Model(Integer.valueOf(i), str)) {
                view.setVisibility(View.GONE);
                return;
            } else {
                view.setVisibility(View.VISIBLE);
                return;
            }
        }
        view.setVisibility(View.GONE);
    }*/

    public static void setImageResource(TextView textView, int i) {
        if (i == 0) {
            textView.setText("");
        } else {
            textView.setText(i);
        }
    }

    public static void setCheck(View view, boolean z) {
        view.setSelected(z);
    }

    public static void setClickSpan(TextView textView, boolean z) {
        if (z) {
            textView.setText(Html.fromHtml("<u>" + ((Object) textView.getText()) + "</u>"));
            return;
        }
        String charSequence = textView.getText().toString();
        charSequence.replace("<u>", "");
        charSequence.replace("</u>", "");
        textView.setText(charSequence);
    }

    public static void setRotateAnimate(View view, boolean z) {
        if (z) {
            RotateAnimation rotateAnimation = new RotateAnimation(0.0f, 360.0f, 1, 0.5f, 1, 0.5f);
            rotateAnimation.setInterpolator(new LinearInterpolator());
            rotateAnimation.setDuration(2000L);
            rotateAnimation.setRepeatCount(-1);
            rotateAnimation.setFillAfter(true);
            rotateAnimation.setStartOffset(10L);
            view.startAnimation(rotateAnimation);
            return;
        }
        view.clearAnimation();
    }

    public static void background(TextView textView, int i) {
        if (i != 0) {
            textView.setBackgroundResource(i);
        }
    }

    public static void date(TextView textView, long j) {
        textView.setText(DateUtil.format(j * 1000, 1));
    }

    public static void dateInSecond(TextView textView, long j) {
        if (j != 0) {
            textView.setText(DateUtil.format(DateUtil.parse(String.valueOf(j), 16), 0));
        }
    }

    public static void locateData(TextView textView, long j) {
        if (j != 0) {
            textView.setText(DateFormat.getMediumDateFormat(textView.getContext()).format(new Date(j * 1000)));
        }
    }

    public static void setDistanceContentText(TextView textView, Double d, String str) {
        textView.setText(FormatterUtil.getNormalFormatDistance(new DistanceUnit(String.valueOf(d), decimalFormat).getValueBy(str)));
    }

    public static void setDistanceUnit(TextView textView, String str) {
        String str2;
        if (str.equals("m")) {
            str2 = UnitConstants.UNIT_SIZE_KM;
        } else {
            str2 = str.equals("f") ? UnitConstants.UNIT_SIZE_MILES : "";
        }
        textView.setText(str2);
    }

    public static void setElevationText(TextView textView, Double d, String str) {
        textView.setText(String.valueOf((int) new AltitudeUnit(String.valueOf(Math.abs(d)), new DecimalFormat("0")).getValueBy(str)));
    }

    public static void setElevationUnit(TextView textView, String str) {
        String str2 = "m";
        if (!str.equals("m")) {
            str2 = str.equals("f") ? UnitConstants.UNIT_SIZE_FT : "";
        }
        textView.setText(str2);
    }

    public static void setAvgGrade(TextView textView, Double d) {
        textView.setText(new DecimalFormat("#0.00").format(d));
    }

    public static void setUserHeight(TextView textView, int i, String str) {
//        double d;
        String str2;
        StringBuilder sb = new StringBuilder();
        sb.append(i / 10.0d);
        String str3 = "";
        sb.append(str3);
        HeightUnit heightUnit = new HeightUnit(sb.toString());
        if (str == null) {
            str2 = str3;
        } else if (str.equals("m")) {
            str2 = heightUnit.getUnitString(str);
//            str3 = ((int) d) + str3;
        } else {
            str3 = heightUnit.inch2Ft(heightUnit.getValueBritish());
            str2 = UnitConstants.UNIT_SIZE_FT;
        }
        if (i == 0) {
            textView.setText(0 + str2);
            return;
        }
        textView.setText(str3 + str2);
    }

    public static void setUserWeight(TextView textView, int i, String str) {
        double d = (i / 1.0d) / 1000.0d;
        StringBuilder sb = new StringBuilder();
        sb.append(d);
        String str2 = "";
        sb.append("");
        WeightUnit weightUnit = new WeightUnit(sb.toString());
        String unitString = str != null ? weightUnit.getUnitString(str) : "";
        if (str != null) {
            if (str.equals("m")) {
                weightUnit.setUpValueWeight(d + "", "m", 1);
                str2 = weightUnit.getValueMetric();
            } else if (str.equals("f")) {
                str2 = weightUnit.getValueBritish();
            }
        }
        textView.setText(str2 + unitString);
    }

    public static void setUserHeartRate(TextView textView, int i, String str) {
        if (i == 0) {
            textView.setText(R.string.device_sprint_settings_turn_off);
            return;
        }
        String heartRateUnit = str != null ? UnitConstants.getHeartRateUnit(str) : "";
        textView.setText(i + heartRateUnit);
    }

    public static void setGearWeight(TextView textView, double d, String str) {
        if (d > Utils.DOUBLE_EPSILON) {
            StringBuilder sb = new StringBuilder();
            double d2 = d / 1000.0d;
            sb.append(d2);
            String str2 = "";
            sb.append("");
            WeightUnit weightUnit = new WeightUnit(sb.toString());
            String unitString = str != null ? weightUnit.getUnitString(str) : "";
            if (str != null) {
                if (str.equals("m")) {
                    weightUnit.setUpValueWeight(d2 + "", "m", 1);
                    str2 = weightUnit.getValueMetric();
                } else if (str.equals("f")) {
                    str2 = weightUnit.getValueBritish();
                }
            }
            textView.setText(str2 + unitString);
            return;
        }
        textView.setText(R.string.gear_edit_hint_desc);
    }

    public static void setDeviceIcon(ImageView imageView, int deviceType, String str) {
        int iconId = R.drawable.ic_device_logo;//default_icon;
        switch (deviceType) {
            case SmartDevice.TYPE_BES -> iconId = R.drawable.ic_add_bikecomputer;
            case SmartDevice.TYPE_HEARTRATE, SmartDevice.TYPE_HEARTRATE_BELT, SmartDevice.TYPE_HEART_RATE01  ->
                    iconId = R.drawable.ic_sensor_logo_heart_rate;
            case SmartDevice.TYPE_POWERRATE ->
                    iconId = R.drawable.ic_sensor_logo_power_rate;
            case SmartDevice.TYPE_BIKE_TRAINER->
                    iconId = R.drawable.ic_sensor_logo_bike_trainer;
            case SmartDevice.TYPE_INDOOR_BIKE ->
                    iconId = R.drawable.ic_ftms_logo_indoor_bike;
            case SmartDevice.TYPE_CROSS_TRAINER ->
                    iconId = R.drawable.ic_ftms_logo_cross_trainer;
            case SmartDevice.TYPE_ROWER ->
                    iconId = R.drawable.ic_ftms_logo_rower;
            case SmartDevice.TYPE_CADENCE -> iconId = R.drawable.ic_device_cadence;//ic_smart_cadence;
            case SmartDevice.TYPE_X1 -> iconId = R.drawable.ic_default;
            case SmartDevice.TYPE_Q1 -> iconId = R.drawable.ic_default;
            case SmartDevice.TYPE_WINGS -> iconId = R.drawable.ic_default;
            case SmartDevice.TYPE_XOSS_G -> {
                if (str != null && !str.isEmpty()) {
                    XossModelUtil.XossGSerial from = XossModelUtil.XossGSerial.Companion.from(str);
                    if (from != null) {
                        switch (from) {
                            case N1, N2 -> iconId = R.drawable.ic_default;
                            case N3, N4 -> iconId = R.drawable.ic_default;
                            case N5 -> iconId = R.drawable.ic_default;
                            case N7 -> iconId = R.drawable.ic_default;
                            case N8 -> iconId = R.drawable.ic_default;
                        }
                    }
                }
            }
            case SmartDevice.TYPE_RADAR_SR -> iconId = R.drawable.ic_default;
            case SmartDevice.TYPE_VORTEX_CADENCE -> iconId = R.drawable.ic_default;
            case SmartDevice.TYPE_CADENCE01 -> iconId = R.drawable.ic_device_cadence;
            case SmartDevice.TYPE_CYCLE_PLUS_M2 -> iconId = R.drawable.ic_default;
            case SmartDevice.TYPE_CHILEAF_600 -> iconId = R.drawable.ic_default;
            case SmartDevice.TYPE_XOSS_NAV -> {
                if (str != null && !str.isEmpty()) {
                    XossModelUtil.XossNAVSerial from2 = XossModelUtil.XossNAVSerial.Companion.from(str);
                    if (from2 != null) {
                        if (from2 == XossModelUtil.XossNAVSerial.A2) {
                            iconId = R.drawable.ic_default;
                        }
                    } else {
                        iconId = R.drawable.ic_device_logo;
                    }
                }
            }
            case SmartDevice.TYPE_CYCLE_PLUS_M1 -> iconId = R.drawable.ic_cycle_plus;
            case SmartDevice.TYPE_LIGHT -> iconId = R.drawable.ic_light_on;
            default -> iconId = R.drawable.ic_device_logo;
        }
        imageView.setImageResource(iconId);
    }

    public static void setWithDeviceName(TextView textView, int i) {
        textView.setText(getDeviceNameResource(i));
    }

    public static void setWithDeviceLogo(ImageView imageView, int i, String str) {
        imageView.setImageResource(getDeviceLogoResource(i, str));
    }

    public static int getDeviceLogoResource(int i, String str) {
        switch (i) {
            case 26:
                return R.drawable.ic_default;
            case 27:
                return R.drawable.ic_default;
            case 28:
                return (str == null || str.equalsIgnoreCase(XossModelUtil.XossNAVSerial.A1.getModel())) ? R.drawable.ic_default : R.drawable.ic_default;
            case 29:
                return R.drawable.ic_cycle_plus;
            default:
                return R.drawable.ic_default;
        }
    }

    public static void getDeviceStateString(TextView textView, XossDeviceConstants.DeviceUIState deviceUIState, int i) {
        textView.setText(getDeviceStateString(textView.getContext(), deviceUIState, i));
    }

    public static String getDeviceStateString(Context context, XossDeviceConstants.DeviceUIState deviceUIState, int i) {
        String string = context.getString(getDeviceNameResource(i));
        if (deviceUIState == null) {
            return context.getString(R.string.st_device_is_offline, string);
        }
        Log.d("wangsm_bt", " DataBindingAdapters, deviceUIState: " + deviceUIState);
        switch (deviceUIState) {
            case OFFLINE_CONNECTION_LOST:
                return context.getString(R.string.st_connecting);
            case CONNECTING:
                return context.getString(R.string.st_connection_lost);
            case CONNECT_FAIL:
                return context.getString(R.string.device_sprint_home_status_connected);
            case CONNECTED:
            case SYNCING:
            case SYNCING_WORKOUT:
                Log.d("wangsm_bt", " DataBindingAdapters, SYNCING");
                return context.getString(R.string.st_syncing);
            case SYNCING_GNSS:
                return context.getString(R.string.st_device_is_recording, string);
            case BUSY:
                return context.getString(R.string.message_upgrade_fw_starting);
            case DFU:
                return context.getString(R.string.Initializing);
            default:
                return "";
        }
    }

    public static void connectState(TextView textView, String str) {
        setDeviceStateString(textView, DeviceHelper.isConnected(str));
    }

    public static void connectStateOrNull(TextView textView, int i) {
        setDeviceStateStringOrNull(textView, DeviceHelper.isConnected(i));
    }

    public static void connectStateOrNull(TextView textView, int i, int i2) {
        if (i2 == 1003 || i == i2) {
            setDeviceStateStringOrNull(textView, DeviceHelper.isConnected(i));
        }
    }

    public static void setDeviceStateString(TextView textView, boolean z) {
        if (z) {
            textView.setText(R.string.device_sprint_home_status_connected);
            textView.setTextColor(textView.getContext().getResources().getColor(R.color.color_gps_green_color));
            return;
        }
        textView.setText(R.string.st_disconnected);
        textView.setTextColor(textView.getContext().getResources().getColor(R.color.grey_999999));
    }

    public static void setDeviceStateStringOrNull(TextView textView, boolean z) {
        if (z) {
            textView.setText(R.string.device_sprint_home_status_connected);
            textView.setTextColor(textView.getContext().getResources().getColor(R.color.color_gps_green_color));
            if (textView instanceof ImageTextView) {
                ((ImageTextView) textView).setDrawable(0, ResourcesCompat.getDrawable(textView.getContext().getResources(), R.drawable.ic_device_connected, null), DensityUtil.dp2px(6.0f), DensityUtil.dp2px(6.0f));
                return;
            }
            return;
        }
        textView.setText("");
        textView.setTextColor(textView.getContext().getResources().getColor(R.color.grey_999999));
        if (textView instanceof ImageTextView) {
            ((ImageTextView) textView).removeDrawable(0);
        }
    }

    public static void setLinkText(TextView textView, boolean z) {
        if (z) {
            textView.setText(new SpanClickHelper(textView.getContext(), new SpanClickHelper.ClickSpanListener() {
                @Override
                public boolean drawUnderLine() {
                    return true;
                }

                @Override
                public int getColor() {
                    return R.color.blue_11aefa;
                }

                @Override
                public void onClick(String str) {
                    Intent intent = new Intent(App.getContext(), WebActivity.class);
                    intent.putExtra("web_url", str);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    App.getContext().startActivity(intent);
                    Log.e("click", "on click link");
                }
            }).getClickableHtml(textView.getText()));
            textView.setMovementMethod(LinkMovementMethod.getInstance());
        }
    }

    public static void setI18Text(TextView textView, String str) {
        SGSettingsConstants.Languagei18n fromType;
        if (str == null || (fromType = SGSettingsConstants.Languagei18n.Companion.fromType(str)) == null) {
            return;
        }
        textView.setText(fromType.getLocaleName());
    }

    public static void getGenderText(TextView textView, int i) {
        SGSettingsConstants.UserGenderTypeDef from = SGSettingsConstants.UserGenderTypeDef.Companion.from(i);
        if (from != null) {
            textView.setText(from.getTypeStrId());
        }
    }

    public static void setUnitTypeText(TextView textView, int i) {
        SGSettingsConstants.UnitTypeDef from = SGSettingsConstants.UnitTypeDef.Companion.from(i);
        if (from != null) {
            textView.setText(from.getUnitNameId());
        }
    }

    public static void setTemperatureUnitText(TextView textView, int i) {
        SGSettingsConstants.TemperatureUnitTypeDef from = SGSettingsConstants.TemperatureUnitTypeDef.Companion.from(i);
        if (from != null) {
            textView.setText(from.getTypeStr());
        }
    }

    public static void setBacklightTypeText(TextView textView, int i) {
        SGSettingsConstants.BacklightTypeDef from = SGSettingsConstants.BacklightTypeDef.Companion.from(i);
        if (from != null) {
            textView.setText(from.getTypeStrId());
        }
    }

    public static void setKeyToneTypeText(TextView textView, boolean z) {
        SGSettingsConstants.KeyToneTypeDef from = SGSettingsConstants.KeyToneTypeDef.Companion.from(z);
        if (from != null) {
            textView.setText(from.getTypeStrId());
        }
    }

    public static void setAutoPauseTypeText(TextView textView, int i) {
        SGSettingsConstants.AutoPauseTypeDef from = SGSettingsConstants.AutoPauseTypeDef.Companion.from(i);
        if (from != null) {
            textView.setText(from.getTypeStrId());
        }
    }

    public static void setUserFtp(TextView textView, int i) {
        textView.setText(i + " w");
    }

    public static void setWheelSize(TextView textView, int i) {
        if (i != 0) {
            textView.setText(i + " mm");
            return;
        }
        textView.setText(R.string.gear_edit_hint_desc);
    }

    public static void setBtnVisibleDelay(final Button button, boolean z) {
        if (!z) {
            button.postDelayed(() -> button.setVisibility(View.VISIBLE), 300L);
        } else {
            button.setVisibility(View.GONE);
        }
    }

    public static void setImageViewVisibleDelay(final ImageView imageView, boolean z) {
        if (!z) {
            imageView.postDelayed(() -> imageView.setVisibility(View.VISIBLE), 300L);
        } else {
            imageView.setVisibility(View.GONE);
        }
    }

    public static void setStorageMemory(TextView textView, long j, long j2) {
        textView.setText(textView.getContext().getString(R.string.st_memory_usage_mb, ((float) (j2 - j)) / 1024.0f, ((float) j2) / 1024.0f));
    }

    public static void setMemoryUsageProgress(ProgressBar progressBar, long j, long j2) {
        if (j2 > 0) {
            float parseFloat = Float.parseFloat(new DecimalFormat("0.00").format((j2 - j) / j2));
            ObjectAnimator.ofInt(progressBar, "progress", (int) (100.0f * parseFloat)).setDuration((long) Math.max(300L, parseFloat * 1000.0f)).start();
            return;
        }
        progressBar.setProgress(0);
    }

    public static void setSpeedContentText(TextView textView, int i, String str) {
        if (i == 0) {
            textView.setText(R.string.device_sprint_settings_turn_off);
            return;
        }
        SpeedUnit speedUnit = new SpeedUnit(Unit.convertcmS2Kmh(i + ""));
        if (str != null) {
            textView.setText(speedUnit.getValueBy(str) + speedUnit.getUnitString(str));
            return;
        }
        textView.setText("");
    }

    public static void fileSize(TextView textView, long j) {
        textView.setText(SizeFormatter.formatFileSize(j));
    }

    public static String getFriendlyTimeInterval(Context context, long j) {
        long currentTimeMillis = (System.currentTimeMillis() - j) / 1000;
        int i = (Long.compare(currentTimeMillis, 60L));
        if (i < 0) {
            return context.getString(R.string.st_just_now);
        }
        if (currentTimeMillis < 3600) {
            long j2 = currentTimeMillis / 60;
            return context.getString(R.string.st_x_minutes_ago, String.valueOf(j2 > 0 ? j2 : 1L));
        } else if (currentTimeMillis < 86400) {
            long j3 = currentTimeMillis / 3600;
            return context.getString(R.string.st_x_hours_ago, String.valueOf(j3));
        } else if (currentTimeMillis < 604800) {
            long j4 = currentTimeMillis / 86400;
            return context.getString(R.string.st_x_days_ago, String.valueOf(j4));
        } else if (currentTimeMillis < 8640000) {
            long j5 = currentTimeMillis / 604800;
            return context.getString(R.string.st_x_weeks_ago, String.valueOf(j5));
        } else {
            long j6 = currentTimeMillis / 8640000;
            return context.getString(R.string.st_x_months_ago, String.valueOf(j6));
        }
    }

    /*public static void setFGDeviceSettingVisible(View view, int i, int i2) {
        if (FGDeviceSettingSupportUtil.Companion.isSupport(i, i2)) {
            view.setVisibility(View.VISIBLE);
        } else {
            view.setVisibility(View.GONE);
        }
    }*/

    /*public static void setSGDeviceSettingVisible(View view, int i, int i2, String str, Integer num) {
        if (i != 17) {
            if (num != null) {
                view.setVisibility(View.VISIBLE);
            } else {
                view.setVisibility(View.GONE);
            }
        } else if (!SGDeviceSettingSupportUtil.Companion.isSupport(i, str, i2)) {
            view.setVisibility(View.GONE);
        } else if (num != null) {
            view.setVisibility(View.VISIBLE);
        } else {
            view.setVisibility(View.GONE);
        }
    }*/

    /*public static void setSGDeviceSettingNoDataLayoutVisible(View view, int i, int i2, String str) {
        if (i == 17) {
            if (SGDeviceSettingSupportUtil.Companion.isSupport(i, str, i2)) {
                view.setVisibility(View.VISIBLE);
                return;
            } else {
                view.setVisibility(View.GONE);
                return;
            }
        }
        view.setVisibility(View.VISIBLE);
    }*/

    /*public static void setFGDeviceUserHeight(TextView textView, SprintDecimal sprintDecimal, String str) {
        String str2 = "";
        if (sprintDecimal == null) {
            str2 = "";
        } else if (str.equals("m")) {
            str2 = getValueDiv10(sprintDecimal.getValue(0, false), "0");
        } else {
            str2 = getValueDiv10(sprintDecimal.getValue(1, false), "0.00");
        }
        if (str2 == null || str2.isEmpty() || Double.parseDouble(str2) == Utils.DOUBLE_EPSILON) {
            return;
        }
        String unitString = str.equals("m") ? new HeightUnit(((int) (Double.parseDouble(str2) / 10.0d)) + "").getUnitString("m") : UnitConstants.UNIT_SIZE_FT;
        textView.setText(str2 + unitString);
    }*/

    /*public static void setFGDeviceUserWeight(TextView textView, SprintDecimal sprintDecimal, String str) {
        String str2 = "";
        String str3 = "";
        if (sprintDecimal != null) {
            if (str.equals("m")) {
                StringBuilder sb = new StringBuilder();
                sb.append(getValueDiv10(Double.parseDouble(sprintDecimal.getValue(0, false)) + ""));
                sb.append("");
                str2 = sb.toString();
            } else if (str.equals("f")) {
                StringBuilder sb2 = new StringBuilder();
                sb2.append(getValueDiv10(Double.parseDouble(sprintDecimal.getValue(1, false)) + ""));
                sb2.append("");
                str2 = sb2.toString();
            }
            if (str2 == null && !str2.isEmpty()) {
                Double.parseDouble(str2);
            }
            return;
        }
        str2 = "";
        if (str2 != null) {
        }
    }*/

    public static void setFGTimeZoneText(TextView textView, float f) {
        String str;
        int i = (Float.compare(f, 0.0f));
        if (i > 0) {
            str = /*Marker.ANY_NON_NULL_MARKER*/"+" + f;
        } else if (i == 0) {
            str = " " + f;
        } else {
            str = HelpFormatter.DEFAULT_OPT_PREFIX + f;
        }
        textView.setText(str);
    }

    public static void setFGAutoPauseTypeText(TextView textView, boolean z) {
        FGSettingsConstants.AutoPauseTypeDef from = FGSettingsConstants.AutoPauseTypeDef.Companion.from(z);
        if (from != null) {
            textView.setText(from.getTypeStrId());
        }
    }

    public static void setFGAutoPauseTypeText(TextView textView, int i) {
        FGSettingsConstants.Language fromType = FGSettingsConstants.Language.Companion.fromType(i);
        if (fromType != null) {
            textView.setText(fromType.getLocaleName());
        }
    }

    public static void setDeviceTimeZoneSettingVisible(View view, String str, Integer num) {
        if (str == null || str.isEmpty()) {
            view.setVisibility(View.GONE);
        } else if (num == 17) {
            if (str.toLowerCase().equals(XossModelUtil.XossGSerial.N7.getModel()) || str.toLowerCase().equals(XossModelUtil.XossGSerial.N8.getModel())) {
                view.setVisibility(View.VISIBLE);
            } else {
                view.setVisibility(View.GONE);
            }
        } else if (num == 28) {
            view.setVisibility(View.VISIBLE);
        }
    }

    public static void setDeviceModelSettingItemVisibility(View view, String str, Integer num) {
        if (str == null || str.isEmpty()) {
            view.setVisibility(View.GONE);
        } else if (str.toLowerCase().equals(XossModelUtil.XossGSerial.N5.getModel()) || str.toLowerCase().equals(XossModelUtil.XossGSerial.N7.getModel())) {
            view.setVisibility(View.GONE);
        } else {
            view.setVisibility(View.VISIBLE);
        }
        if (num == null) {
            view.setVisibility(View.GONE);
        }
    }

    public static void setDeviceModelSettingItemVisibility(View view, int i, Integer num) {
        if (i == 0) {
            view.setVisibility(View.GONE);
        } else if (i == 17) {
            view.setVisibility(View.GONE);
        } else {
            view.setVisibility(View.VISIBLE);
        }
        if (num == null) {
            view.setVisibility(View.GONE);
        }
    }

    /*public static void setFGSpeedContentText(TextView textView, SprintDecimal sprintDecimal, String str) {
        String str2 = "";
        if (sprintDecimal != null) {
            if (str.equals("m")) {
                str2 = getValueDiv10(sprintDecimal.getValue(0, false));
            } else if (str.equals("f")) {
                str2 = getValueDiv10(sprintDecimal.getValue(1, false));
            }
            if (str2 == null && !str2.isEmpty() && Double.parseDouble(str2) > Utils.DOUBLE_EPSILON) {
                DecimalFormat decimalFormat2 = new DecimalFormat("0");
                decimalFormat2.setDecimalFormatSymbols(dfs);
                String str3 = str.equals("m") ? "m" : "f";
                SpeedUnit speedUnit = new SpeedUnit(str2 + "", str3, decimalFormat2);
                textView.setText(str2 + speedUnit.getUnitString(str3));
                return;
            }
            textView.setText(R.string.device_sprint_settings_turn_off);
        }
        str2 = "";
        if (str2 == null) {
        }
        textView.setText(R.string.device_sprint_settings_turn_off);
    }*/

    public static String getValueDiv10(String str) {
        BigDecimal multiply = new BigDecimal(str).multiply(new BigDecimal("0.1"));
        DecimalFormat decimalFormat2 = new DecimalFormat("0.0");
        decimalFormat2.setDecimalFormatSymbols(dfs);
        decimalFormat2.setMinimumFractionDigits(0);
        return decimalFormat2.format(multiply);
    }

    public static String getValueDiv10(String str, String str2) {
        BigDecimal multiply = new BigDecimal(str).multiply(new BigDecimal("0.1"));
        DecimalFormat decimalFormat2 = new DecimalFormat(str2);
        decimalFormat2.setDecimalFormatSymbols(dfs);
        return decimalFormat2.format(multiply);
    }

    public static String getValueX10(String str) {
        BigDecimal multiply = new BigDecimal(str).multiply(new BigDecimal(Constants.VIA_REPORT_TYPE_SHARE_TO_QQ));
        DecimalFormat decimalFormat2 = new DecimalFormat("0.0");
        decimalFormat2.setDecimalFormatSymbols(dfs);
        decimalFormat2.setMinimumFractionDigits(0);
        return decimalFormat2.format(multiply);
    }

    public static void hrBodySensor(ImageView imageView, String str, BodySensorLocation bodySensorLocation) {
        if (bodySensorLocation != null) {
            if (bodySensorLocation == BodySensorLocation.Hand) {
                imageView.setImageResource(R.drawable.ic_default);
            } else if (str != null) {
                if (str.toLowerCase().contains("x2")) {
                    imageView.setImageResource(R.drawable.ic_default);
                }
            } else {
                imageView.setImageResource(R.drawable.ic_default);
            }
        }
    }

    public static void setSGTimeZoneText(TextView textView, long j) {
        String str;
        String str2;
        String str3;
        long j2 = j / 3600;
        if (Math.abs(j2) < 10) {
            str = "0" + Math.abs(j2);
        } else {
            str = Math.abs(j2) + "";
        }
        if (j2 >= 0) {
            str2 = /*Marker.ANY_NON_NULL_MARKER*/"+" + str;
        } else {
            str2 = HelpFormatter.DEFAULT_OPT_PREFIX + str;
        }
        long abs = (Math.abs(j) - (Math.abs(j2) * 3600)) / 60;
        if (abs == 0) {
            str3 = str2 + ":00";
        } else {
            str3 = str2 + Separators.COLON + abs;
        }
        textView.setText("GMT" + str3);
    }

    public static void setEnable(View view, Boolean bool) {
        if (bool != null) {
            view.setEnabled(bool);
        }
    }

    public static void setLightStateView(ImageView imageView, LightDeviceState lightDeviceState) {
        if (lightDeviceState != null) {
            if (lightDeviceState == LightDeviceState.OFF) {
                imageView.setImageResource(R.drawable.ic_default);
                return;
            } else if (lightDeviceState == LightDeviceState.ON) {
                imageView.setImageResource(R.drawable.ic_light_on);
                return;
            } else if (lightDeviceState == LightDeviceState.UNCONNECTED) {
                imageView.setImageResource(R.drawable.ic_default);
                return;
            } else {
                imageView.setImageResource(R.drawable.ic_default);
                return;
            }
        }
        imageView.setImageResource(R.drawable.ic_default);
    }

    public static void setLightOpenView(ImageView imageView, LightDeviceState lightDeviceState) {
        if (lightDeviceState != null) {
            if (lightDeviceState == LightDeviceState.OFF) {
                imageView.setVisibility(View.VISIBLE);
                imageView.setImageResource(R.drawable.ic_light_switcher_off);
                return;
            } else if (lightDeviceState == LightDeviceState.ON) {
                imageView.setVisibility(View.VISIBLE);
                imageView.setImageResource(R.drawable.ic_light_switcher_on);
                return;
            } else if (lightDeviceState == LightDeviceState.UNCONNECTED) {
                imageView.setVisibility(View.GONE);
                return;
            } else {
                imageView.setVisibility(View.GONE);
                return;
            }
        }
        imageView.setVisibility(View.GONE);
    }

    public static void setLightStateText(TextView textView, LightDeviceState lightDeviceState) {
        if (lightDeviceState != null) {
            if (lightDeviceState == LightDeviceState.OFF) {
                textView.setText(R.string.device_detail_state_connected);
                return;
            } else if (lightDeviceState == LightDeviceState.ON) {
                textView.setText(R.string.device_detail_state_connected);
                return;
            } else {
                textView.setText(R.string.device_detail_state_disconnect);
                return;
            }
        }
        textView.setText(R.string.device_detail_state_disconnect);
    }

    public static void setLightTypeName(TextView textView, LightMachineStatus lightMachineStatus) {
        if (lightMachineStatus != null && lightMachineStatus.getLightType() != null) {
            switch (lightMachineStatus.getLightType()) {
                case Headlight:
                    textView.setText(R.string.st_headlight);
                    return;
                case TailLight:
                    textView.setText(R.string.st_tail_light);
                    return;
                case ConfigurableSignalLight:
                    textView.setText(R.string.st_configurable_signal_light);
                    return;
                case LeftSignalLight:
                    textView.setText(R.string.st_right_signal_light);
                    return;
                case RightSignalLight:
                    textView.setText(R.string.st_left_signal_light);
                    return;
                case Reserved1:
                    textView.setText("");
                    return;
                default:
                    return;
            }
        }
        textView.setText("");
    }

    public static void setBatteryImg(ImageView imageView, int i) {
        if (i >= 0 && i <= 25) {
            imageView.setImageResource(R.drawable.ic_default);
        } else if (25 < i && i <= 50) {
            imageView.setImageResource(R.drawable.ic_default);
        } else if (50 < i && i <= 75) {
            imageView.setImageResource(R.drawable.ic_default);
        } else if (75 < i && i <= 100) {
            imageView.setImageResource(R.drawable.ic_default);
        } else {
            imageView.setImageResource(R.drawable.ic_default);
        }
    }

    public static void setBatteryImg(ImageView imageView, BatteryStatus batteryStatus) {
        if (batteryStatus == BatteryStatus.Low) {
            imageView.setImageResource(R.drawable.ic_default);
        } else if (batteryStatus == BatteryStatus.Middle) {
            imageView.setImageResource(R.drawable.ic_default);
        } else if (batteryStatus == BatteryStatus.Good) {
            imageView.setImageResource(R.drawable.ic_default);
        } else if (batteryStatus == BatteryStatus.Reserved || batteryStatus == BatteryStatus.Full || batteryStatus == BatteryStatus.Charging) {
            imageView.setImageResource(R.drawable.ic_default);
        } else {
            imageView.setImageResource(R.drawable.ic_default);
        }
    }
}
